Recently, an image compression technique represented by the MPEG (Moving Picture Experts Group) has been being developed.
FIG. 1 shows a configuration of a conventional image coding apparatus 1 which uses such MPEG as mentioned above.
Referring to FIG. 1, a macro block division section 11 receives frame data as an input thereto, converts the frame data into data of a macro block (hereinafter referred to as MB), and outputs the data of the MB obtained by the conversion to a subtraction section 19, a quantization scale determination section 18 and a reference image production section 17.
The subtraction section 19 subtracts reference image data inputted from the reference image production section 17 from the data of the MB inputted from the macro block division section 11 (namely, the subtraction section 19 adds the reference image data in the reversed polarity to the data of the MB) and outputs difference data to a DCT section 12.
The DCT section 12 performs a DCT (Discrete Consign Transform) process for the difference data inputted from the subtraction section 19 to convert them into DCT coefficients and outputs the DCT coefficients to a quantization section 13.
The quantization section 13 quantizes the DCT coefficients inputted from the DCT section 12 with a quantization scale inputted from a quantization scale determination section 18 and outputs resulting values to a VLC section 14 and a decoding section 16.
The VLC section 14 performs a variable length coding process for the quantized data inputted from the quantization section 13 to convert the data into a VLC (Variable Length Code) and outputs the VLC to a transmission buffer section 15.
The transmission buffer section 15 outputs the VLC inputted thereto to the quantization scale determination section 18. Meanwhile, the transmission buffer section 15 converts, when the VLCs of the entire frame are inputted thereto, the VLCs into data in a unit of a frame and outputs the data as bit stream data to the outside.
In the decoding section 16, a dequantization section 21 dequantizes the quantized data inputted from the quantization section 13 and outputs resulting data to an inverse DCT section 22.
The inverse DCT section 22 performs an inverse DCT process for the dequantized data inputted from the dequantization section 21 into original image data and outputs the original image data to an addition section 34 of the reference image production section 17.
In the reference image production section 17, the addition section 34 adds image data inputted from the inverse DCT section 22 and reference image data, which is inputted from a motion compensation buffer section 31 and corresponding to the image data, and outputs resulting data to the motion compensation buffer section 31 through a motion compensation section 32.
The motion compensation buffer section 31 stores the image data inputted from the addition section 34 through the motion compensation section 32 as predictive image data for a next frame.
A motion detection arithmetic operation section 33 detects a motion vector corresponding to the MB inputted from the macro block division section 11 and outputs the motion vector to the motion compensation section 32.
The motion compensation section 32 performs a process for motion compensation, based on the motion vector inputted from the motion vector arithmetic operation section 33. In particular, the motion compensation section 32 reads out reference image data, which is corresponding to the data of the MB inputted to the subtraction section 19, from among the predictive image data stored in advance in the motion compensation buffer section 31, based on the motion vector inputted from the motion detection arithmetic operation section 33, and outputs the reference image data to the subtraction section 19.
In the quantization scale determination section 18, a complexity arithmetic operation section 46 calculates, based on the VLC inputted. from the transmission buffer section 15, a complexity as a parameter representative of complicacy of the VLC and outputs the complexity to a complexity buffer section 45.
The complexity buffer section 45 temporarily stores the complexity inputted from the complexity arithmetic operation section 46 and suitably outputs the complexity to a target code amount arithmetic operation section 41.
The target code amount arithmetic operation section 41 calculates a target code amount based on the complexity inputted from the complexity buffer section 45 and outputs the target code amount to a quantization index arithmetic operation section 42.
The quantization index arithmetic operation section 42 calculates a quantization index based on the target code amount inputted from the target code amount arithmetic operation section 41 and outputs the quantization index to a quantization scale arithmetic operation section 43.
An activity arithmetic operation section 44 calculates an activity as a parameter representative of complicacy of data of each of the MBs inputted from the macro block division section 11 and outputs the activity to the quantization scale arithmetic operation section 43.
The quantization scale arithmetic operation section 43 calculates a quantization scale based on the quantization index inputted from the quantization index arithmetic operation section 42 and the activity inputted from the activity arithmetic operation section 44 and outputs the quantization scale to the quantization section 13.
Subsequently, operation of the image coding apparatus 1 is described.
Frame data are inputted to the macro block division section 11 and converted into data in a unit of an MB and then outputted to the subtraction section 19.
Reference image data inputted from the reference image production section 17 to the subtraction section 19 are subtracted from the data of the MB inputted to the subtraction section 19, and data of the difference between them is outputted to the DCT section 12.
The difference data inputted to the DCT section 12 is converted into a DCT coefficient, and the DCT coefficient is outputted to the quantization section 13. The DCT coefficient inputted to the quantization section 13 is quantized based on a quantization scale inputted from the quantization scale arithmetic operation section 43 to the quantization section 13 and then inputted to the VLC section 14.
The quantized data inputted to the VLC section 14 is converted into a VLC, and the VLC is outputted to the transmission buffer section 15.
The VLC inputted to the transmission buffer section 15 is outputted to the complexity arithmetic operation section 46. When VLCs of the entire frame are inputted to the transmission buffer section 15, the VLCs are converted into data in a unit of a frame, and the data are outputted as bit stream data to the outside.
The quantized data inputted from the quantization section 13 to the dequantization section 21 is dequantized and outputted to the inverse DCT section 22. The dequantized data inputted to the inverse DCT section 22 is converted back into original image data, and the original image data is outputted to the addition section 34.
The image data inputted to the addition section 34 is added to the reference image data (that is, reference image data obtained by the subtraction from the data of the MB by the subtraction section 19) stored in the motion compensation buffer section 31 in advance and then decoded.
The decoded data of the MB is inputted to the motion compensation buffer section 31 through the motion compensation section 32 and stored as predictive image data of an MB of a frame to be processed subsequently.
The motion detection arithmetic operation section 33 detects a motion vector corresponding to the data of the MB inputted from the macro block division section 11 and outputs the motion vector to the motion compensation section 32.
By the motion compensation section 32, a process of motion compensation corresponding to the motion vector inputted from the motion detection arithmetic operation section 33 is performed. In particular, from within the predictive image data stored in advance in the motion compensation buffer section 31, the predictive image data at a position displaced by an amount corresponding to the motion vector from the position of the MB is read out, and the predictive image data is outputted as reference image data for the MB to the subtraction section 19.
The quantization scale determination section 18 performs the following three process, that is, so-called TM5 (Test Model 5) processes of the MPEG to calculate a quantization scale of the MB and outputs the quantization scale of the MB to the quantization section 13.
(Step 1)
The target code amount arithmetic operation section 41 calculates, based on the value of the complexity of the VLC of the MB inputted from the complexity buffer section 45 and processed at the k-th (the MB processed at the k-1th is hereinafter referred to as MB-k-1), a target code amount for the MB-k, and outputs the target code amount to the quantization index arithmetic operation section 42.
(Step 2)
The quantization index arithmetic operation section 42 calculates a virtual buffer occupation amount of the MB-k, based on the target code amount for the MB-k inputted from the target code amount 41.
Further, the quantization index arithmetic operation section 42 calculates a quantization index of the MB-k based on the virtual buffer occupation amount of the MB-k and outputs the quantization index of the MB-k to the quantization scale arithmetic operation section 43.
(Step 3)
The quantization scale arithmetic operation section 43 calculates a quantization scale, based on the quantization index of the MB-k inputted from the quantization index arithmetic operation section 42 and the value of the activity of the MB-k inputted from the activity arithmetic operation section 44, and outputs the quantization scale to the quantization section 13.
At (step 2) of the TM5 described above, the quantization index (hereinafter referred to as Q-k) of the MB-k is calculated in accordance with the following two expressions:d-k=d0+Bk-1−(Tk×(k-1)/mbcnt  (1)Q-k=d-k×31/r  (2)
The expression (1) is an expression for determining the virtual buffer occupation amount (hereinafter referred to as d-k) of the MB-k.
d0 represents an initial virtual buffer occupation amount at the top of the frame; Bk-1 represents the generation bit amount up to the preceding MB, that is, the MB-k-1; mbcnt represents the total number of MBs per one frame; and Tk represents the target code amount for the MB-k.
The expression (2) is an expression for determining the quantization index Q-k of the MB-k.
r represents a parameter for adjusting the speed of response of feedback of the quantization scale determination section 18 and is called reaction parameter.
The quantization indices of the MBs calculated in accordance with such expressions (1) and (2) as given above have the following problem.
In particular, the quantization indices of the MBs calculated by the feedback loop of the quantization scale determination section 18 are calculated based on the prerequisite that the generation code amounts of the MBs are all equal to each other.
As a result, there is a problem that, where the generation code amounts of the MBs are not equal to each other, the quantization indices in the frame are not stabilized.
For example, it is assumed that a frame 51 of FIG. 2 is divided into totaling mbcnt MBs composed of an MB group 52 having a large amount of information, that is, a large amount of bit generation and another MB group 53 having a small amount of bit generation.
Then, it is assumed that the data of the MB-1 to MB-mbcnt obtained by the conversion are coded by the image coding apparatus 1 of FIG. 1.
In this instance, the d-1 to d-mbcnt (virtual buffer occupation amounts of the MB-1 to MB-mbcnt) calculated in accordance with the expression (1) given hereinabove are such as indicated by a curve 54 of FIG. 3.
It is to be noted that the axis of ordinate of FIG. 3 indicates the virtual buffer occupation amount d and the axis of abscissa represents the order k (k ranges from 1 to mbcnt) of the coding process of the MBs.
In particular, as seen from the curve 54 of FIG. 3, in the front half of the coding process (where k is small), the virtual buffer occupation amount d-k increases in accordance with the processing order (as k increases). On the other hand, in the latter half of the coding process (where k is great), the virtual buffer occupation amount d-k decreases in accordance with the processing order (as k increases toward the mbcnt).
Accordingly, since the quantization index Q-k increases in proportion to the virtual buffer occupation amount d-k as indicated by the expression (2) given hereinabove, the calculated quantization indices, Q-1 to Q-mbcnt, have values dispersed, depending upon the value of k.
In other words, the quantization indices of the MBs calculated by the image coding apparatus 1 are not stable within the frame.
As a result, the visual perceptibility, that is, the picture quality, of the frame coded by the image coding apparatus 1 of FIG. 1 is degraded.